package nullby.omnia.fragment;

import nullby.common.utils.CustomLog;
import nullby.omnia.R;
import nullby.omnia.activity.voc.ActivityVocabulareList;
import nullby.omnia.helper.DialogHelper;
import nullby.omnia.helper.DialogHelper.DIALOG_TYPE;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class FragmentSettings extends Fragment implements OnClickListener {

	public static final String TAG = FragmentSettings.class.getSimpleName();

	private View bUser;
	private Button bLang;
	private Button bView;
	private Button bBackground;
	private Button bVoc;
	private Button bWebsite;
	private Button bReview;
	private Button bAbout;

	public static FragmentSettings newInstance() {
		FragmentSettings fragment = new FragmentSettings();
		return fragment;
	}

	public FragmentSettings() {
		super();
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		CustomLog.logI(TAG, "onActivityCreated");
		super.onActivityCreated(savedInstanceState);
		bUser = (View) getActivity().findViewById(R.id.bUser);
		bLang = (Button) getActivity().findViewById(R.id.bLang);
		bView = (Button) getActivity().findViewById(R.id.bView);
		bBackground = (Button) getActivity().findViewById(R.id.bBackground);
		bVoc = (Button) getActivity().findViewById(R.id.bVoc);
		bWebsite = (Button) getActivity().findViewById(R.id.bWebsite);
		bReview = (Button) getActivity().findViewById(R.id.bReview);
		bAbout = (Button) getActivity().findViewById(R.id.bAbout);
		bAbout.setOnClickListener(this);
		bUser.setOnClickListener(this);
		bLang.setOnClickListener(this);
		bView.setOnClickListener(this);
		bBackground.setOnClickListener(this);
		bVoc.setOnClickListener(this);
		bWebsite.setOnClickListener(this);
		bReview.setOnClickListener(this);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		CustomLog.logI(TAG, "onCreateView");
		return inflater.inflate(R.layout.fragment_settings, container, false);
	}

	@Override
	public void onClick(View v) {
		Integer id = v.getId();
		CustomLog.logD(TAG, "Click");
		if (id == R.id.bUser) {
		} else if (id == R.id.bLang) {
			showListDialog(DIALOG_TYPE.LANG);
		} else if (id == R.id.bView) {
			showListDialog(DIALOG_TYPE.VIEW);
		} else if (id == R.id.bBackground) {
			showListDialog(DIALOG_TYPE.BACKGROUND);
		} else if (id == R.id.bVoc) {
			startActivity(new Intent(getActivity(), ActivityVocabulareList.class));
		} else if (id == R.id.bWebsite) {
		} else if (id == R.id.bReview) {
		} else if (id == R.id.bAbout) {
		}

	}

	private void showListDialog(DialogHelper.DIALOG_TYPE typeDialog) {
		new DialogHelper(typeDialog).show(getFragmentManager(), TAG);
	}

}
